import pandas as pd
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

from utils import find_element_click, find_element_input

driver = webdriver.Edge()


# 后续操作 pandas openyxl，xlrd，，操作excel
# 读取excel数据源
def ModifyWC(driver):
    df = pd.read_excel("./Excel/70岁以上.xlsx")
    for idx, row in df.iterrows():
        证件号码 = row["证件号码"]
        print(证件号码)
        try:
            # Selenium问题-无法定位元素：{"method":"css selector"，"selector“-需要帮助解决此问题
            # 出现无法定位元素时使用原始写法可得到错误提示：driver.find_element(By.ID, "")
            # 参考网址https://cloud.tencent.com/developer/ask/sof/1221860
            find_element_input(driver, By.ID, "aab004", 证件号码)
        except Exception as e:
            print("等了10秒没有找到相应元素链接，无法输入，错误：", e)
        # print(idx)
        find_element_click(driver, By.ID, "on_query")
